The second Mini Project focused on real data collected via wearable devices from a fellow FPU Graduate student. While the project he is focusing on uses machine learning techniques to predict risk of hypertension in young adults - I sought to provide meaningful visualizations from the data collected via the wearable devices or participants themselves.
This project required three datasets - one of which is an .shp file containing Florida Zip Code geometries from Koordinates two of which are pulled from my very unorganized GitHub Repo. After using several iterations of the join() function (none of which appeared to be of my liking), the merge() function was used to back-door join the datasets.
Through a great deal of frustration and stress, eventually, I was able to use the join function for the geometry data to join the Zip Codes of participants. :sweat_smile:
When first creating the map, I very quickly realized just how small zip codes were - they are really small in Florida. This lead to some issues in terms of visualization - the map of Florida was great - the filling of participants by their zip codes? Not so much.. This was eventually resolved by deciding to use an interactive map - we can zoom in to see the variation of participants in the Central Florida area.
library(ggrepel)
#create map filling by frequency of ZIPCODE appearing
pmap <- participant_map %>%
ggplot()+
geom_sf(aes(fill = n), color = "white") +
theme_light() +
guides(fill= guide_legend(reverse=TRUE)) +
theme(aspect.ratio = 0.8, panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
labs(title="BioDatix Participants", caption = "Source: BioDatix Participant Data") +
labs(fill="Participants") +
scale_fill_continuous()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(htmlwidgets)
p <- ggplot(participant_map) + geom_sf(aes(fill=n))
ggplotly(p) %>%
highlight(
"plotly_hover",
selected = attrs_selected(line = list(color = "white"))
)